<?php
// +----------------------------------------------------------------------
// |RoleModel.class.php
// +----------------------------------------------------------------------
// |Data:2015-01-09 13:43
// +----------------------------------------------------------------------
// |Author: 吕志雄 <870923001@qq.com>
// +----------------------------------------------------------------------
namespace Admin\Model;
use Common\Model\BaseDbModel;
use Common\Model\CommonModel;

class AuthGroupModel extends CommonModel{
    protected $tableName = 'auth_group';

    /**
     * 更新角色明细
     * @param $table
     * @param $data
     * @return bool
     */
    public function updateAccess($data,$role_id){
        return parent::update($data,$role_id);
    }


    /**
     * 删除规则明细表
     * @param $where
     * @return bool
     */
    public function deleteAccess($role_id){
        return parent::del($role_id);
    }



    /**
     * 获取提示字段
     * @param $where
     * @return string
     */
    public function getTipField($table,$where,$field){
        return M($table)->where($where)->getField($field);
    }

    /**
     * 获取角色用户
     * @param $where
     * @return array
     */
    public function getRoleUserId($where){
        $list = M()->table(C('DB_PREFIX').'auth_group_access as a')
            ->join('left join '.C('DB_PREFIX').'manage as b on a.uid=b.id')
            ->field('b.*')
            ->where($where)
            ->cache(5)
            ->select();

        foreach($list as $value){
            $ids[] = $value['id'];
        }
        return $ids;
    }

    /**
     * 获取用户
     * @return mixed
     */
    public function getUser(){
        $map['id'] = array('neq',C('MANAGE_id'));
        $list = M('manage')->where($map)->cache(5)->select();
        return $list;
    }
}
?>